/*
** tex.c for  in /home/guicqu_g//rush/epikong/etape_1
** 
** Made by gallien guicquero
** Login   <guicqu_g@epitech.net>
** 
** Started on  Sat Mar 26 13:13:55 2011 gallien guicquero
** Last update Sun Mar 27 15:58:30 2011 gallien guicquero
*/

#include "mlx.h"
#include "window.h"
#include "tex.h"

int	texture_loader(t_p *p, t_i *i, char *filename)
{
  if ((i->img = mlx_xpm_file_to_image(p->mlx, filename, &i->sx, &i->sy)) == 0)
      return (-1);
  i->data = mlx_get_data_addr(i->img, &i->bpp, &i->sl, &i->endian);
  return (0);
}

int	textures_loader(t_p *p)
{
  texture_loader(p, &p->tex[0], "wall.xpm");
  texture_loader(p, &p->tex[1], "monster.xpm");
  texture_loader(p, &p->tex[2], "ladder.xpm");
  texture_loader(p, &p->tex[3], "hero.xpm");
  texture_loader(p, &p->tex[4], "output.xpm");
  texture_loader(p, &p->tex[5], "key.xpm");
  return ((!p->tex[0].img || !p->tex[1].img || !p->tex[2].img ||
	   !p->tex[3].img || !p->tex[4].img || !p->tex[5].img) ? -1 : 0);
}
